package org.cycuchy.hp.data {
	
	import mx.collections.ArrayCollection;
	import mx.collections.Sort;
	
	public class EmPeCzysData {
	
		public var empeczys:ArrayCollection;

		public static function xml2EmPeCzysData(xml:XML):EmPeCzysData {
			var data:EmPeCzysData = new EmPeCzysData();
			var emepeczys:ArrayCollection = new ArrayCollection();
			var empeczy:EmPeCzyData;
			for each(var k:XML in xml.list.empeczy) {
				empeczy = new EmPeCzyData;
				empeczy.empeczyName = k.@name;
				empeczy.empeczyUrl = k.@url;
				emepeczys.addItem(empeczy);				
			}
			
			var sort:Sort = new Sort();
			sort.compareFunction = function (a:Object, b:Object, fields:Array = null):int {
				return Math.round(Math.random()*-1+Math.random());
			};
			emepeczys.sort = sort;
			emepeczys.refresh();
			
			data.empeczys = emepeczys;
			return data;
		}			
	}
	
}